CREATE PROCEDURE coreAuditSearchEvents
(
	@searchText nvarchar(1024),
	@severity   int,
	@uid		int,
	@typeid		int,
	@class		nvarchar(50),
	@app		nvarchar(200),
	@start		datetime,
	@end		datetime	
)
AS

SELECT * FROM EventLog WHERE 
	Message			LIKE @searchText
AND Severity		>= @severity
AND DateTimeStamp	>= @start
AND DateTimeStamp	<= @end
AND ((FK_User=@uid) OR (@uid=0))
AND ((Type=@typeID) or (@typeID=0))
AND ((Class=@class) or (@class=''))
AND ((App=@app) or (@app=''))
ORDER BY DateTimeStamp DESC;
